home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / Blitting Class Library / Buffer Accessors / GWorldAccessor.cp < prev    next >
Encoding:
Text File  |  1995-11-18  |  1.4 KB  |  50 lines  |  [TEXT/CWIE]

  1. // GWorldAccessor.cp, the GWorldAccessor class, to be used for direct access to
  2. //    GWorld pixel-maps.
  3.  
  4. // copyright © 1995, Macneil Shonle. All rights reserved.
  5.  
  6. #ifndef __GWORLDACCESSOR__
  7. #include <GWorldAccessor.h>
  8. #endif
  9.  
  10. // sets up direct blitting information for an offscreen graphics world
  11. //    may throw: xalloc
  12. GWorldAccessor::GWorldAccessor(GWorldPtr gw) throw(xalloc)
  13. {
  14.     construct(gw);
  15. }
  16.  
  17. // intentionally left blank
  18. GWorldAccessor::~GWorldAccessor()
  19. {
  20. }
  21.  
  22. // makes a copy of the given GWorldAccessor
  23. //    may throw: xalloc
  24. GWorldAccessor& GWorldAccessor::operator=(const GWorldAccessor& gwa) throw(xalloc)
  25. {
  26.     this->BufferAccessor::operator=(gwa);
  27.     return *this;
  28. }
  29.  
  30. // caches in the given GWorld's pixel information
  31. //    may throw: xalloc
  32. GWorldAccessor& GWorldAccessor::operator=(GWorldPtr gw) throw(xalloc)
  33. {
  34.     construct(gw);
  35.     return *this;
  36. }
  37.  
  38. // private member-function to implement the construction of the BufferAccessor for
  39. // an offscreen graphics world
  40. //    may throw: xalloc
  41. void GWorldAccessor::construct(GWorldPtr gw) throw(xalloc)
  42. {
  43.     theHeight = gw->portRect.bottom - gw->portRect.top;
  44.     theWidth = gw->portRect.right - gw->portRect.left;
  45.     
  46.     PixMapHandle gwPixMap = ::GetGWorldPixMap(gw);
  47.     theRowBytes = (*gwPixMap)->rowBytes & 0x3FFFL;            // see QD 15-RowBytes Revealed II
  48.     setArray(PixelPtr(::GetPixBaseAddr(gwPixMap)), theRowBytes, theHeight);
  49.     mmuMode = ::PixMap32Bit(gwPixMap);
  50. }